package Practice.object;

public class Packet {
    public static void main(String[] args) {
        Integer i1 = new Integer(5);
        Integer i2 = new Integer(5);
        System.out.println(i1 == i2);//false
        System.out.println(i1.equals(i2));//true ,包装类重写了equals()比较的值


        //valueOf()方法会复用1个字节(-128到127)范围内的数据，建议使用valueOf()
        Integer i3 = Integer.valueOf(5);
        Integer i4 = Integer.valueOf(5);
        System.out.println(i3 == i4); //true
        System.out.println(i3.equals(i4)); //true，包装类重写equals()比较值了

        //将包装类转换为基本类型
        int i = i4.intValue();
        System.out.println(i);
        int i5 = i3.intValue();
        System.out.println(i5);


        int max = Integer.MAX_VALUE;
        int min = Integer.MIN_VALUE;
        System.out.println(max);
        System.out.println(min);


        String s1 = "2123";
        int t1 = Integer.parseInt(s1);
        System.out.println(t1);//转换为int类型
        String s2 = "13.31213";
        double d1  = Double.parseDouble(s2);
        System.out.println(d1);//转换为double类型


    }
}
